<% content_for :head do %>
		<%= stylesheet_link_tag 'blogs' %>
		<%= stylesheet_link_tag 'ueditor_comment' %>
<% end %>

<!--1.编辑器js-->
<%= javascript_include_tag 'ueditor/ueditor_config' %>
<%= javascript_include_tag 'ueditor/editor_api' %>
<%= javascript_include_tag 'ueditor/lang/zh-cn/zh-cn' %>
<%= javascript_include_tag 'ueditor/ueditor_all_min' %>
<%= javascript_include_tag 'ueditor/ueditor_parse_min' %>


<!--代码高亮-->
<%= stylesheet_link_tag 'shCoreDefault' %>
<%= javascript_include_tag 'ueditor/third-party/SyntaxHighlighter/shCore' %>

<script type="text/javascript">
		SyntaxHighlighter.all();
</script>



<div class="container">

	<div class="section">
		<div class="alert alert-warning"><h2><%= @show_blog.title.html_safe %></h2>
			<%= link_to '<< 返回', list_blogs_path, :class => 'btn btn-warning dropdown-toggle' %>
		</div>
	</div>

	<hr>

	<p>作者：chris <i class="icon-pencil"> </i>发表于：<%= @show_blog.created_at.strftime('%Y-%m-%d') %> 评论：0 浏览：0</p>

	<div class="well">
		<%= @show_blog.content.html_safe %>
	</div>

	<!--百度分享  待改进	-->
	<div class="bdsharebuttonbox">
		<a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
	</div>
	<script>window._bd_share_config = {"common": {"bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "24"}, "share": {}, "image": {"viewList": ["qzone", "tsina", "tqq", "renren", "weixin"], "viewText": "Share一下：", "viewSize": "24"}, "selectShare": {"bdContainerClass": null, "bdSelectMiniList": ["qzone", "tsina", "tqq", "renren", "weixin"]}};
	with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script>

	<div>
		<%= link_to '编辑', edit_blog_path, :class => 'btn btn-info' %>
	</div>

	<hr>

	<div class="lead well">
		<!--上一篇，下一篇-->
		<%= render 'up_and_next_blog' %>
	</div>

	<div class="lead well">
		<!--相关博文-->
		<%= render 'same_tag_blogs' %>
	</div>

	<div class="lead well">
		<!--博文评论-->
		<%= render 'blog_comments' %>
	</div>

	<div class="comments_content">
		<div class="blog-content-spacing">
			<!--2.编辑器初始化-->
			<script id="editor" type="text/plain" style="width:1140px;height:200px;"></script>
		</div>
		<div class="form-group">
			<input type="hidden" name="blog_id" id="blog_id" value="<%= @show_blog.id %>">
			<input type="submit" class="btn btn-warning btn-block buttonOrg btn-lg submitComment" value="评论提交"/>
		</div>
	</div>
	<!--3.编辑器初始化-->
	<script type="text/javascript">
			//实例化编辑器
			//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
		  UE.getEditor('editor');
			function isFocus(e) {
					alert(UE.getEditor('editor').isFocus());
					UE.dom.domUtils.preventDefault(e)
			}
			function setblur(e) {
					UE.getEditor('editor').blur();
					UE.dom.domUtils.preventDefault(e)
			}
			function insertHtml() {
					var value = prompt('插入html代码', '');
					UE.getEditor('editor').execCommand('insertHtml', value)
			}
			function createEditor() {
					enableBtn();
					UE.getEditor('editor');
			}
			function getAllHtml() {
					alert(UE.getEditor('editor').getAllHtml())
			}
			function getContent() {
					var arr = [];
					arr.push("使用editor.getContent()方法可以获得编辑器的内容");
					arr.push("内容为：");
					arr.push(UE.getEditor('editor').getContent());
					alert(arr.join("\n"));
			}
			function getPlainTxt() {
					var arr = [];
					arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
					arr.push("内容为：");
					arr.push(UE.getEditor('editor').getPlainTxt());
					alert(arr.join('\n'))
			}
			function setContent(isAppendTo) {
					var arr = [];
					arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
					UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
					alert(arr.join("\n"));
			}
			function setDisabled() {
					UE.getEditor('editor').setDisabled('fullscreen');
					disableBtn("enable");
			}

			function setEnabled() {
					UE.getEditor('editor').setEnabled();
					enableBtn();
			}

			function getText() {
					//当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
					var range = UE.getEditor('editor').selection.getRange();
					range.select();
					var txt = UE.getEditor('editor').selection.getText();
					alert(txt)
			}

			function getContentTxt() {
					var arr = [];
					arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
					arr.push("编辑器的纯文本内容为：");
					arr.push(UE.getEditor('editor').getContentTxt());
					alert(arr.join("\n"));
			}
			function hasContent() {
					var arr = [];
					arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
					arr.push("判断结果为：");
					arr.push(UE.getEditor('editor').hasContents());
					alert(arr.join("\n"));
			}
			function setFocus() {
					UE.getEditor('editor').focus();
			}
			function deleteEditor() {
					disableBtn();
					UE.getEditor('editor').destroy();
			}
			function disableBtn(str) {
					var div = document.getElementById('btns');
					var btns = domUtils.getElementsByTagName(div, "button");
					for (var i = 0, btn; btn = btns[i++];) {
							if (btn.id == str) {
									domUtils.removeAttributes(btn, ["disabled"]);
							} else {
									btn.setAttribute("disabled", "true");
							}
					}
			}
			function enableBtn() {
					var div = document.getElementById('btns');
					var btns = domUtils.getElementsByTagName(div, "button");
					for (var i = 0, btn; btn = btns[i++];) {
							domUtils.removeAttributes(btn, ["disabled"]);
					}
			}

			function getLocalData() {
					alert(UE.getEditor('editor').execCommand("getlocaldata"));

			}

			function clearLocalData() {
					UE.getEditor('editor').execCommand("clearlocaldata");
					alert("已清空草稿箱")
			}

			$('#content').on('click', function () {
					var content = UE.getEditor('editor').getContent(),
									$input = $('.input-content');
					$input.val(content);
			});
	</script>
</div>


<%= javascript_include_tag 'blogs' %>